# 定义列表
goods = ['食品', '服装', '鞋帽', '餐具', '家具']

a = [1, '123', [1, 2, 3]]

# 统计列表的长度
goods = ['食品', '服装', '鞋帽', '餐具', '家具']
print(len(goods))

# 从列表中提取单个元素
goods = ['食品', '服装', '鞋帽', '餐具', '家具']
a = goods[2]
b = goods[-1]
print(a)
print(b)

# 从列表中提取多个元素
goods = ['食品', '服装', '鞋帽', '餐具', '家具']
a = goods[1:4]
print(a)

goods = ['食品', '服装', '鞋帽', '餐具', '家具']
a = goods[1:]
b = goods[-3:]
c = goods[:2]
d = goods[:-2]
print(a)
print(b)
print(c)
print(d)

# 添加一个列表元素
goods = ['食品', '服装', '鞋帽', '餐具', '家具']
goods.append('化妆品')
print(goods)

# 添加多个列表元素
goods = ['食品', '服装', '鞋帽', '餐具', '家具']
goods.extend(['化妆品', '玩具'])
print(goods)

goods = ['食品', '服装', '鞋帽', '餐具', '家具']
goods += ['化妆品', '玩具']
print(goods)

# 列表与字符串的相互转换
goods = ['食品', '服装', '鞋帽', '餐具', '家具']
a = '/'.join(goods)
print(a)
b = a.split('/')
print(b)

# 定义字典
goods = {'食品': 656, '服装': 1640, '鞋帽': 549, '餐具':1312, '家具': 235}

# 从字典中提取元素
goods = {'食品': 656, '服装': 1640, '鞋帽': 549, '餐具':1312, '家具': 235}
print(goods['鞋帽'])

# 在字典中添加和修改元素
goods = {'食品': 656, '服装': 1640, '鞋帽': 549, '餐具':1312, '家具': 235}
goods['服装'] = 1109
goods['化妆品'] = 784
print(goods)
